﻿using System;
using System.Data;
using System.Data.SqlClient;
using System.ComponentModel;
using NovinMedia.Data;

using asscope.configuration;

namespace asscope.Data.Layer
{
    [DataObject(true)]
    public class Games
    {
        [DataObjectMethod(DataObjectMethodType.Fill)]
        public DataSet SelectAll()
        {
            DbObject dbo = new DbObject();
            SqlParameter[] parameters = new SqlParameter[]
                {
 
                };
            return dbo.RunProcedure("sp_games_SelectAll", parameters, "games");
        }

        [DataObjectMethod(DataObjectMethodType.Fill)]
        public DataSet SelectRow(string game_uid, string docno)
        {
            DbObject dbo = new DbObject();
            SqlParameter[] parameters = new SqlParameter[]
                {
					new SqlParameter("game_uid",game_uid),
					new SqlParameter("docno",docno) 
                };
            return dbo.RunProcedure("sp_games_SelectRow", parameters, "games");
        }

        [DataObjectMethod(DataObjectMethodType.Insert)]
        public int InsertRow(string game_uid, string docno, string game_name, string game_title, string sport_code, DateTime created_on, DateTime updated_on, DateTime duedate_on)
        {
            int RowsAffected = 0;
            int Result = 0;
            DbObject dbo = new DbObject();
            SqlParameter[] parameters = new SqlParameter[]
				{
					new SqlParameter("game_uid",game_uid),
					new SqlParameter("docno",docno),
					new SqlParameter("game_name",game_name),
					new SqlParameter("game_title",game_title),
					new SqlParameter("sport_code",sport_code),
					new SqlParameter("created_on",created_on),
					new SqlParameter("updated_on",updated_on),
					new SqlParameter("duedate_on",duedate_on) 
				};
            Result = dbo.RunProcedure("sp_games_Insert", parameters, out RowsAffected);
            return Result;
        }

        [DataObjectMethod(DataObjectMethodType.Update)]
        public int UpdateRow(string game_uid, string docno, string game_name, string game_title, string sport_code, DateTime created_on, DateTime updated_on, DateTime duedate_on)
        {
            int RowsAffected = 0;
            int Result = 0;
            DbObject dbo = new DbObject();
            SqlParameter[] parameters = new SqlParameter[]
				{
					new SqlParameter("game_uid",game_uid),
					new SqlParameter("docno",docno),
					new SqlParameter("game_name",game_name),
					new SqlParameter("game_title",game_title),
					new SqlParameter("sport_code",sport_code),
					new SqlParameter("created_on",created_on),
					new SqlParameter("updated_on",updated_on),
					new SqlParameter("duedate_on",duedate_on) 
				};
            Result = dbo.RunProcedure("sp_games_Update", parameters, out RowsAffected);
            return Result;
        }

        [DataObjectMethod(DataObjectMethodType.Delete)]
        public int DeleteRow(string game_uid, string docno)
        {
            int RowsAffected = 0;
            int Result = 0;
            DbObject dbo = new DbObject();
            SqlParameter[] parameters = new SqlParameter[]
				{
					new SqlParameter("game_uid",game_uid),
					new SqlParameter("docno",docno) 
				};
            Result = dbo.RunProcedure("sp_games_DeleteRow", parameters, out RowsAffected);
            return Result;
        }
    }
}